<?php
class DataTypeForms {
	
	private $datatypes = array(); //Holder for building up the forms
	private $formButtons = false;
	
	
	function add($title = '', $dataType = '', $extra = array()){
		$this->datatypes[] = array('title'=>$title,'type'=>$dataType, 'extra'=>$extra);
	}
	
	function addButtons(){
		$this->formButtons = true;
	}
	
	function draw($dataTypeMode, $formMode , TableBase $dataTypeObj, $token ){
		$html = '';
		if( $this->datatypes ){
			$html = '<form action="form/tableClassDialogPost" method="POST" class="form-horizontal d-edit-form" enctype="multipart/form-data">';
			
			foreach($this->datatypes as $info){
				$html .= twitter_ControlGroup($info['title'],$dataTypeObj->dataType($info['type'], $dataTypeMode, $info['extra']));
			}
			if( $this->formButtons ){
				$html .= twitter_FormActions();
			}
			$html .= '<input name="key" type="hidden" value="'.$dataTypeObj->getFormKey().'" />';
			$html .= '<input name="token" type="hidden" value="'.$token.'" />';
			$html .= '<input name="tableClassAction" type="hidden" value="'.$formMode.'" />';
			$html .= '</form>';
		}
		echo($html);
	}
	
}
?>
